package org.example.common.base.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@ApiModel(description = "分页结果响应")
public class MultiResult<T> extends Result<List<T>> {

    @ApiModelProperty(value = "总记录数", example = "100")
    private long total;

    @ApiModelProperty(value = "当前页码", example = "1")
    private int page;

    @ApiModelProperty(value = "每页记录数", example = "10")
    private int size;

    @ApiModelProperty(value = "是否具有下一页", example = "false")
    private Boolean nextPage;

    public MultiResult() {
        super();
    }

    public MultiResult(Boolean success, int code, String message, List<T> data, long total, int page, int size) {
        super(success, code, message, data);
        this.total = total;
        this.page = page;
        this.size = size;
    }

    public MultiResult(Boolean success, int code, String message, List<T> data, long total, int page, int size, boolean nextPage) {
        super(success, code, message, data);
        this.total = total;
        this.page = page;
        this.size = size;
        this.nextPage = nextPage;
    }

    public MultiResult(Boolean success, int code, String message, List<T> data, long total, int page, int size, boolean nextPage, ExtData extData) {
        super(success, code, message, data, extData);
        this.total = total;
        this.page = page;
        this.size = size;
        this.nextPage = nextPage;
    }

    public static <T> MultiResult<T> successMulti(List<T> data, long total, int page, int size) {
        return new MultiResult<>(true, SUCCESS_CODE, SUCCESS_MSG, data, total, page, size);
    }

    public static <T> MultiResult<T> successMulti(List<T> data, long total, int page, int size, boolean nextPage) {
        return new MultiResult<>(true, SUCCESS_CODE, SUCCESS_MSG, data, total, page, size, nextPage);
    }

    public static <T> MultiResult<T> successMulti(List<T> data, long total, int page, int size, boolean nextPage, ExtData extData) {
        return new MultiResult<>(true, SUCCESS_CODE, SUCCESS_MSG, data, total, page, size, nextPage, extData);
    }

    public static <T> MultiResult<T> errorMulti(int errorCode, String errorMsg) {
        return new MultiResult<>(false, errorCode, errorMsg, null, 0, 0, 0);
    }

}
